﻿using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Reflection;

namespace Community.SharePoint.FAST.PowerShell
{
    [RunInstaller(true)]
    public partial class HelpFileInstaller : System.Configuration.Install.Installer
    {
        public HelpFileInstaller()
        {
            InitializeComponent();
        }

        protected override void OnAfterInstall(IDictionary savedState)
        {
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string fileName = Path.Combine(path, "Community.SharePoint.FAST.PowerShell.dll-help.xml");

            var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Community.SharePoint.FAST.PowerShell.Community.SharePoint.FAST.PowerShell.dll-help.xml");
            var reader = new StreamReader(stream);
            File.WriteAllText(fileName, reader.ReadToEnd());
            base.OnAfterInstall(savedState);
        }
    }
}
